//企业版Login
var $ = require('jquery')
require('lib/modules/jquery-validation')
var Base64 = require('lib/modules/base64').Base64
$(function(){
  $('#username').focus();
  $('input').change(function(){
      $('.server-error').remove()
  })
  $('#loginform').validate({
      submitHandler:function(form,ev){
        var $form = $(form)
        var $password = $form.find('[name="password"]')
        var $encode = $form.find('[name="encode"]')
        if($encode.length){
          try{
              $password.val(Base64.btoa($password.val()))
              $encode.val('true')
          }catch(e){

          }
        }
        return true
      },
      errorLabelContainer:'.field-error',
      rules:{
          username:{
              required:true
          },

          password:{
              required:true
          }

      },
      messages: {
          username: {
              required: '请输入用户名'
          },
          password: {
              required: '请输入密码'
          }
      }
  });
});
